-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Openapi property based testing #172
Conversation
test/support/requests_generator.ex
Outdated
|
||
# basic types | ||
defp nonempty_string() do | ||
StreamData.string(:alphanumeric) |> StreamData.filter(fn x -> String.length(x) > 0 end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like (or whatever the correct syntax is)
StreamData.string(:alphanumeric) |> StreamData.filter(fn x -> String.length(x) > 0 end) | |
StreamData.string(:alphanumeric, min_length: 1) |
Note that StreamData.string/2
can take the same options than list_of/1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch 😀
looks good. please recheck Nelson's suggestion. |
b8988fd
to
bba7d83
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 😄
This PR introduces property-based approach to APIv3 testing, with a little help of
StreamData
framework. I also incorporated the fix/enhancement of 'the hack of the hack' introduced in #168. Shortly speaking, the request containing, from the needed fields, onlydata
,alert/body
andalert/title
fields, was matched againstSilentNotification
schema, what has been leading to improperUnexpected field: alert
error.I also improved
ControllersHelper.missing_field_response
helper function to better reflect possible error messages we can encounter during tests, basing on the API version being used.